package com.hzhr.iot.collect.protocol.processor;

import com.hzhr.iot.collect.constant.MessageFieldKeyEnum;
import com.hzhr.iot.collect.protocol.util.MessageUtil;
import com.hzhr.iot.collect.util.StrUtil;
import com.hzhr.iot.core.util.HzhrDateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 集中器 注册包
 * @author 48310
 *
 */
@Component
public class MessageProcessor76 implements MessageProcessor {
	@Autowired
	MessageUtil messageUtil;

	@Override
	public List<Map<MessageFieldKeyEnum, Object>> proccess(int protocolId, String deviceId, Map<MessageFieldKeyEnum, Object> parsedMessageObj) throws Exception {
		List<Map<MessageFieldKeyEnum, Object>> responseMsgList = new ArrayList<Map<MessageFieldKeyEnum, Object>>();
		String ccrNo = StrUtil.removeZeroForLeft(parsedMessageObj.get(MessageFieldKeyEnum.IOT_DEVICE_ID).toString());
		Map<MessageFieldKeyEnum, Object> respMsg = this.messageUtil.generateCcrResponse(protocolId, parsedMessageObj, "0000", ccrNo);
		Date date = new Date();
		respMsg.put(MessageFieldKeyEnum.RESP_BIAOZHUNRIQI, HzhrDateUtil.dateToStr(date, "yyyyMMdd"));
		respMsg.put(MessageFieldKeyEnum.RESP_BIAOZHUNSHIJIAN, HzhrDateUtil.dateToStr(date, "HHmmss"));
		responseMsgList.add(respMsg);
		return responseMsgList;
	}
}
